import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        // 初始化Spring容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationContext.class);

        // 获取订单服务实例
        OrderService orderService = context.getBean(OrderService.class);

        System.out.println("=== 测试添加商品 ===");
        try {
            orderService.add("苹果", 5);
        } catch (Exception e) {
            System.out.println("添加商品失败: " + e.getMessage());
        }

        System.out.println("\n=== 测试删除商品 ===");
        try {
            orderService.delete("香蕉");
        } catch (Exception e) {
            System.out.println("删除商品失败: " + e.getMessage());
        }

        System.out.println("\n=== 测试查询商品 ===");
        try {
            orderService.find("橘子");
        } catch (Exception e) {
            System.out.println("查询商品失败: " + e.getMessage());
        }

        // 关闭容器
        context.close();
    }
}
    